package com.example.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * @author ：fbb
 * @version ：1.0
 * @since 2022-02-12 17:44
 */
@RequestMapping
@RestController
public class AxiosController {
    @GetMapping  ("/getUser")
    public Object axiosRequest(String id,String param01,String param02
           ){
        System.out.println(id);
        System.out.println(param01);
        System.out.println(param02);
        HashMap<String, Object> map = new HashMap<>();
        map.put("code",200);
        map.put("msg","请求成功");
        return  map;
    }
    @PostMapping  ("/getUser01")
    public Object axiosRequest01(@RequestBody String param01) throws JsonProcessingException {
        System.out.println(param01);
        ObjectMapper mapper = new ObjectMapper();
        JsonNode jsonNode = mapper.readTree(param01);
        JsonNode param011 = jsonNode.get("param01");
        String s = param011.asText();
        System.out.println(s);
        System.out.println(s);
        HashMap<String, Object> map = new HashMap<>();
        map.put("code",200);
        map.put("msg","请求成功");
        return  map;
    }
}
